#include <iostream>
using namespace std;
int main()
{
	int t;
	while(cin>>t){
		for(int i=0;i<t;i++){
			string s1,s2;
			cin>>s1>>s2;
			for(int j=s2.length()-1;j>=0;j--){
				if(s2[j]==' '||(s2[j]>='0'&&s2[j]<='9')) continue;
				else cout<<s2[j];
			}
			for(int j=s1.length()-1;j>=0;j--){
				if(s1[j]==' '||(s1[j]>='0'&&s1[j]<='9')) continue;
				else cout<<s1[j];
			}
			cout<<endl;
		}
	}
}
